package com.yaolong.api.modules.gen.config;


import com.yaolong.api.modules.gen.constants.GenConstants;

import java.util.Map;

/**
 * @author yaolong
 * @version V1.0.0
 * @program EasyCode
 * @description 输出的template
 * @create 2022-12-29 23:23
 **/
public class CustomOutputTemplateResultConfig {
    /**
     * 前端代码
     */
    private Map<String,String> frontEndCode;
    /**
     * 后台代码
     */
    private Map<String,String> afterEndCode;
    /**
     * sql代码
     */
    private Map<String,String> sqlCode;
    /**
     * 其他代码
     */
    private Map<String,String> otherCode;


    /**
     * 总文件个数 -- 用于判断是否输出文件完毕
     */
    private Integer fileTotalCount;

    /**
     * 当前输出个数 -- 用于判断是否输出文件完毕
     */
    private Integer currentOutputCount = 0;


    //TODO 这里的属性 currentOracleMenuId、currentOracleMenuMetaId、currentMysqlMenuId、currentMysqlMenuMetaId 后续考虑用map或者bean来存储比较合理
    /**
     * =============================BEGIN-系统表在ORACLE数据库中 数据库脚本生成缓存记录====================
     * 当前菜单id-生成sql文件的菜单id需要记录一下
     */
    private Integer currentOracleMenuId = 0;

    /**
     * 当前菜单meta id-生成sql文件的菜单metaid需要记录一下
     */
    private Integer currentOracleMenuMetaId = 0;

    /**
     * 当前接口id
     */
    private Integer currentPermissionId = 0;

    public Integer getCurrentPermissionId() {
        return currentPermissionId;
    }

    public void setCurrentPermissionId(Integer currentPermissionId) {
        this.currentPermissionId = currentPermissionId;
    }

    public Integer getCurrentOracleMenuMetaId() {
        return currentOracleMenuMetaId;
    }

    public void setCurrentOracleMenuMetaId(Integer currentMenuMetaId) {
        this.currentOracleMenuMetaId = currentMenuMetaId;
    }

    public Integer getCurrentOracleMenuId() {
        return currentOracleMenuId;
    }

    public void setCurrentOracleMenuId(Integer currentMenuId) {
        this.currentOracleMenuId = currentMenuId;
    }
    /**
     * =============================END-系统表在ORACLE数据库中 数据库脚本生成缓存记录====================
     */



    /**
     * =============================BEGIN-系统表在MYSQL数据库中 数据库脚本生成缓存记录====================
     * 当前菜单id-生成sql文件的菜单id需要记录一下
     */
    private Integer currentMysqlMenuId = 0;

    /**
     * 当前菜单meta id-生成sql文件的菜单metaid需要记录一下
     */
    private Integer currentMysqlMenuMetaId = 0;


    public Integer getCurrentMysqlMenuMetaId() {
        return currentMysqlMenuMetaId;
    }

    public void setCurrentMysqlMenuMetaId(Integer currentMenuMetaId) {
        this.currentMysqlMenuMetaId = currentMenuMetaId;
    }

    public Integer getCurrentMysqlMenuId() {
        return currentMysqlMenuId;
    }

    public void setCurrentMysqlMenuId(Integer currentMenuId) {
        this.currentMysqlMenuId = currentMenuId;
    }

    /*
     * =============================END-系统表在MYSQL数据库中 数据库脚本生成缓存记录====================
     */


    /**
     * 多表代码生成时，保证id连续性，这里直接计算自增（主要是根据生成菜单的条数自增，和按钮菜单的条数自增）
     */
    public void increaseCurrentMenuId(String dbType){
        if (GenConstants.DB_TYPE_ORACLE.equals(dbType)){
            this.currentOracleMenuId++;
            this.currentOracleMenuMetaId++;
        } else if (GenConstants.DB_TYPE_MYSQL.equals(dbType)){
            this.currentOracleMenuId++;
            this.currentOracleMenuMetaId++;
        }
    }

    /**
     * 是否输出完毕
     */
    public Boolean isOutputDone(){
        return this.currentOutputCount >= fileTotalCount;
    }


    public void increaseFileCount(){
        this.currentOutputCount++;
    }


    public Integer getFileTotalCount() {
        return fileTotalCount;
    }

    public Integer getCurrentOutputCount() {
        return currentOutputCount;
    }

    public void setFileTotalCount(Integer fileTotalCount) {
        this.fileTotalCount = fileTotalCount;
    }

    public Map<String, String> getFrontEndCode() {
        return frontEndCode;
    }

    public void setFrontEndCode(Map<String, String> frontEndCode) {
        this.frontEndCode = frontEndCode;
    }

    public Map<String, String> getAfterEndCode() {
        return afterEndCode;
    }

    public void setAfterEndCode(Map<String, String> afterEndCode) {
        this.afterEndCode = afterEndCode;
    }

    public Map<String, String> getSqlCode() {
        return sqlCode;
    }

    public void setSqlCode(Map<String, String> sqlCode) {
        this.sqlCode = sqlCode;
    }

    public Map<String, String> getOtherCode() {
        return otherCode;
    }

    public void setOtherCode(Map<String, String> otherCode) {
        this.otherCode = otherCode;
    }
}
